package teacher.action;

import java.text.SimpleDateFormat;
import java.util.Date;

import teacher.bean.Award;
import teacher.bean.Flow;
import teacher.bean.Paper;
import teacher.service.flow;
import teacher.service.paper;

import com.opensymphony.xwork2.ActionSupport;

public class modifyPap extends ActionSupport{
	private Paper pap;
	private int paperId;

	public Paper getPap() {
		return pap;
	}

	public void setPap(Paper pap) {
		this.pap = pap;
	}

	public int getPaperId() {
		return paperId;
	}

	public void setPaperId(int paperId) {
		this.paperId = paperId;
	}

	public String execute(){
		
		pap=new paper().selectPaperById(paperId);
		
//		流程管理部分
		Paper a=new Paper();
		a=new flow().selectPaperByName(this.getPap().getName());
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Flow f=new Flow();
		f.setFruitId(a.getPapId());
		f.setFruitKind(1);
		f.setDirDo(2);
		f.setDirTime(df.format(new Date()));
		f.setSubDo(2);
		f.setSubTime(df.format(new Date()));
		f.setTeaDo(3);
		f.setTeaTime(df.format(new Date()));
//		流程管理结束
		if(new flow().insertFlow(f)){
			if(pap.getType()==0){
				return SUCCESS;
				}else{
					return ERROR;
				}
		}else{
			if(pap.getType()==0){
				return SUCCESS;
				}else{
					return ERROR;
				}
		}
		
		
		
	} 

}